//
//  LiveModel.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/14.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "LiveModel.h"
#import "ListArrayModel.h"

@implementation LiveModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if(self = [super init])
    {
        self.footballArray = [NSMutableArray array];
        self.basketballArray = [NSMutableArray array];
        self.importantFootball = [NSMutableArray array];
        self.importantBasketball = [NSMutableArray array];
        [self setValuesForKeysWithDictionary:dict];
        self.list = [dict objectForKey:@"list"];
        for(NSDictionary *matchDict in self.list)
        {
            self.listModel =[ListArrayModel listArrayModelWithDict:matchDict ];
            if ([self.listModel.type isEqualToString:@"football"] || [self.listModel.type isEqualToString:@"basketball"]) {
                if (!([self.listModel.home_team isEqualToString:@"福利"] || [self.listModel.home_team isEqualToString:@""])) {

                    NSString *str = [self.listModel.title substringToIndex:1];
                    
                    if ([self.listModel.type isEqualToString:@"football"]) {
                        [self.footballArray addObject:self.listModel];
                        if ([str isEqualToString:@"<"]) {
                            [self.importantFootball addObject:self.listModel];
                        }
                    }
                    else
                    {
                        [self.basketballArray addObject:self.listModel];
                        if ([str isEqualToString:@"<"]) {
                            [self.importantBasketball addObject:self.listModel];
                        }
                    }
                    self.listModel.title = [[self.listModel.title stringByReplacingOccurrencesOfString:@"<b>" withString:@""]stringByReplacingOccurrencesOfString:@"</b>" withString:@""];
                    NSArray *array = [self.listModel.title componentsSeparatedByString:@" "];
                    self.listModel.matchProperty = array[0];
                    self.listModel.matchInfo = [NSString stringWithFormat:@"%@ vs %@",self.listModel.home_team,self.listModel.visit_team];
                }
            }
        }
    }
    return self;
}

+ (instancetype)liveWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}



@end
